#include <cstdlib>

#include "lcg.h"

int16_t CLcg::getRand()
{
    if (mModulo <= 0)
        return -1;
    if (mMultiplier >= mModulo || mMultiplier < 1)
        return -1;
    if (mIncrement >= mModulo || mIncrement < 0)
        return -1;
    if (ggt(mMultiplier, mModulo) != 1)
        return -1;

    mSeed = ((mMultiplier * mSeed) + mIncrement) % mModulo;

    return mSeed;
}
